﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.ObjectBuilder;
using Microsoft.Practices.CompositeWeb;
using CMSWCSFSolution.CMS.Interface.Services;
using CMS.Model;

namespace CMSWCSFSolution.CMS.Views
{
    public class UpdateStudentPresenter : Presenter<IUpdateStudentView>
    {
        private ICMSService _service;
        public UpdateStudentPresenter([CreateNew] ICMSService service)
        {
            _service = service;
        }
        /// <summary>
        /// Called when [selected all grades].
        /// </summary>
        public void OnSelectedAllGrades()
        {
              View.BindClass=_service.GetAllGrades();
        }
        /// <summary>
        /// Called when [select student by id].
        /// </summary>
        /// <returns></returns>
        public Student OnSelectStudentById()
        {
            int studentId = View.StudentId;
            Grade grade=new Grade();
            Student stu = new Student(grade);
            stu = _service.GetStudentById(studentId);
            return stu;
        }
        /// <summary>
        /// Called when [update student].
        /// </summary>
        public void OnUpdateStudent()
        {
            Grade grade = new Grade();
            Student student = new Student(grade);
            student = View.studentUpdate;
            _service.UpdateStudent(student);
        }
        public override void OnViewLoaded()
        {
        }
        public override void OnViewInitialized()
        {
        }
    }
}




